'use strict';
// 零配置简化, 详情：https://www.yuque.com/easy-team/easywebpack/v4
const path = require("path")
const resolve = dir => {
    return path.join(__dirname, dir)
}
const isDev = process.env.NODE_ENV === "development"
module.exports = {
    // egg: true,
    devtool: isDev ? "source-map" : "eval", //eval
    target: 'web',
    framework: "vue",
    entry: {
        home: path.join(__dirname, "web/index.js")
    },
    // proxy: {
    //     host:  'http://106.52.33.75:1601',
    //     match: /\/login/
    // },
    cssExtract: !isDev,
    compile: {
        thread: true, // 多进程编译
        cache: true // 启动编译缓存
    },
    alias: {
        _commonJs: resolve("web/common/js"),
        "@": resolve("web"),
        _commonStyle: resolve("web/common/style"),
        _commonImg: resolve("web/common/img"),
        _comp: resolve("web/common/components"),
        _libs: resolve("web/libs"),
        _mixins: resolve("web/mixins"),
        _request: resolve("web/request"),
        _router: resolve("web/router"),
        _store: resolve("web/store"),
        _views: resolve("web/views"),
    },
    // 正式环境使用长缓存
    publicPath: isDev ? "" : "/static/",
    dll: [
        "vue",
        "vue-router",
        "vuex",
        "axios",
        "js-cookie",
    ],
    externals: {
        vue: "Vue",
        "vue-router": "VueRouter",
        vuex: "Vuex",
        axios: "axios"
    },
    plugins: [
        {
            imagemini: false
        },
        {
            uglifyJs: {
                args: {
                    uglifyOptions: {
                        warnings: false,
                        compress: {
                            dead_code: !isDev,
                            drop_console: !isDev,
                            drop_debugger: !isDev
                        },
                        output: {
                            comments: false
                        }
                    }
                }
            }
        }
    ]
};
